package xgenerator.ui.swing;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class BackgroundImageLabel extends JLabel {
	
	private ImageIcon backgroundImage;

	public BackgroundImageLabel(String path) {
		super(IconUtils.createImageIcon(path));
		this.backgroundImage = (ImageIcon) this.getIcon();
		this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
		if(null != backgroundImage) {
			this.setBounds(0, 0, backgroundImage.getIconWidth(), backgroundImage.getIconHeight());  //null布局时，移动组件并调整其大小。由 x 和 y 指定左上角的新位置，由 width 和 height指定新的大小
		}
	}
}
